package com.tj.bo.payment.server.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.fqgj.common.utils.CollectionUtils;
import com.tj.bo.payment.server.dao.PaymentOrderDao;
import com.tj.bo.payment.server.entity.PaymentOrderEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
* User: anonymous
* Date: 2021-07-16
* Time: 11:30:38.999
*/

@Repository
public class PaymentOrderDaoImpl extends AbstractBaseMapper<PaymentOrderEntity> implements PaymentOrderDao {
    @Override
    public PaymentOrderEntity getByOrderCode(String orderCode) {
        return  getSqlSession().selectOne("selectByOrderCode", orderCode);
    }

    @Override
    public List<String> queryOrderCode(Integer orderStatus, Integer orderType) {
        Map<String, Object> map = new HashMap<>();
        map.put("deleted", 0);
        map.put("type", orderType);
        map.put("status", orderStatus);
        List<PaymentOrderEntity> list = this.selectByParams(map);
        if (CollectionUtils.isNotEmpty(list)){
            return list.stream()
                    .map(PaymentOrderEntity::getOrderCode)
                    .collect(Collectors.toList());
        }
        return null;
    }
}